<%--
  Created by IntelliJ IDEA.
  User: W
  Date: 2025/9/28
  Time: 16:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<label for="region">区域：</label>
<input type="text" id="region">
<input type="button" value="查询" id="search">
<table>
    <thead>
    <tr>
        <th>代理商ID</th>
        <th>代理商编号</th>
        <th>代理商名称</th>
        <th>代理商区域</th>
    </tr>
    </thead>
    <tbody id="dataBox"></tbody>
</table>
</body>
</html>

<script type="text/javascript" src="js/jquery-3.6.0.js"></script>
<script type="text/javascript">
    $(function () {
        $("#search").click(function () {
            //  使用定位的元素去加载searchAgents的处理结果
            // var regionValue = $("#region").val();
            // $("#dataBox").load("searchAgents?region="+encodeURIComponent(regionValue));
            $.ajax({
                url: 'searchAgents',
                type: 'get',
                data: {
                    region: $("#region").val()
                },
                success: function (resp) {
                    let tbody = $("#dataBox");
                    tbody.empty();
                    for (let i = 0; i < resp.length; i++) {
                        let tr = $("<tr>");
                        tr.append($("<td>" + resp[i].aid + "</td>"))
                        tr.append($("<td>" + resp[i].ano + "</td>"))
                        tr.append($("<td>" + resp[i].aname + "</td>"))
                        tr.append($("<td>" + resp[i].aregion + "</td>"))
                        tr.append($("</tr>"));
                        tbody.append(tr);
                    }
                }
            })
        });
    })
</script>
